package com.yiyuan.app.dao;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.guaike.core.mybatis.plugins.BaseDAO;
import com.yiyuan.app.entity.enums.RepairStatusEnum;
import com.yiyuan.app.entity.po.GRoomRepairRecordPO;
import com.yiyuan.app.mapper.GRoomRepairRecordMapper;
import org.springframework.stereotype.Repository;

@Repository
public class GRoomRepairRecordDAO extends BaseDAO<GRoomRepairRecordMapper, GRoomRepairRecordPO> {


    public int updateNormal(Long roomId) {
        LambdaUpdateWrapper<GRoomRepairRecordPO> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.set(GRoomRepairRecordPO::getStatus, RepairStatusEnum.normal.getCode());
        updateWrapper.eq(GRoomRepairRecordPO::getRoomId, roomId);
        updateWrapper.eq(GRoomRepairRecordPO::getStatus, RepairStatusEnum.repairing.getCode());
        return getBaseMapper().update(new GRoomRepairRecordPO(), updateWrapper);
    }
}
